<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 输入三角形的层数
        let n = parseInt(prompt("请输入三角形的高"));
        // n = 4;
        let row = n + 1;
        for (let i = 1; i <= row; i++) {
            // 空格数
            // 打印空格
            for (let y = 2 * n + 1; y >= 2 * i - 1; y = y - 1) {

                let space = document.write("#");


            }
            // 打印*号
            for (let z = 1; z <= 2 * i - 1; z++) {

                let star = document.write("*");

            }
            let star = document.write("<br />");
        }
    </script>
</body>

</html>